package it.fuesi.synotools.constants;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by pascotto on 20/10/14.
 */
public enum ApiErrorKey {

    DuplicateTask("error_task_queue_add_dup_file", "Duplicate download"),
    UnkownError("unkown", "Unkown Error"),
    NoPrivilege("error_noprivilege", "No privileges");



    private String errorKey;
    private String errorMessage;

    public String getErrorKey(){return this.errorKey;}
    public String getErrorMessage(){return this.errorMessage;}

    ApiErrorKey(String errorKey, String errorMessage){
        this.errorKey = errorKey;
        this.errorMessage = errorMessage;
    }

    private static final Map<String, ApiErrorKey> mapping = getMapping();

    private static final Map<String, ApiErrorKey> getMapping(){
        final Map<String, ApiErrorKey> map = new HashMap<String, ApiErrorKey>();
        for(ApiErrorKey a : ApiErrorKey.values()){
            map.put(a.errorKey, a);
        }
        return map;
    }

    public static final ApiErrorKey get(String key){
        if(mapping.containsKey(key))
            return mapping.get(key);
        else
            return ApiErrorKey.UnkownError;
    }



}
